<?php
namespace  Teachers\Controller;
use Think\Controller;
/**
 * 校园景色
 * 
 * */
class CommentController extends CommonController
{
	/**
     * 点评管理
     */
    public function index() {
        $pagesize=1;
        $school_id=$this->showschoolID();
        $SchoolComment = M('SchoolComment');
       
        $map['school_id'] = $school_id;
       
        $map['status'] = 0;
        $count = $SchoolComment->where($map)->count(); // 查询满足要求的总记录数
        
        
        
        $Page       = new \Think\Page($count,$pagesize,$state=0);
        
//        $Page = new PageController($count, 6); // 实例化分页类 传入总记录数和每页显示的记录数(25)
        $show = $Page->show(); // 分页显示输出
        $School_data = $SchoolComment->where($map)->limit($Page->firstRow . ',' . $Page->listRows)->select();
      
        $this->assign('comment', $School_data);
        $this->assign('page', $show); // 赋值分页输出	
        $this->display();
    }

    /*
     * 查看点评功能 
     * 
     *   */

    public function commentselect() {
       
        $comment_id = I("post.comment_id");
        $map['comment_id'] = $comment_id;
        $SchoolComment = M('SchoolComment');
        $comment = $SchoolComment->where($map)->find();
//        echo $SchoolComment->_Sql();
//        print_r($comment);
        $this->ajaxReturn($comment);
    }

    /*
     * 删除点评 
     * 假删除把status状态该为1
     *          */

    public function commentsdelete() {
       
//        $school_id = I("get.school_id");
        $comment_id = I("post.comment_id");
//        $map['school_id'] = $school_id;
        $map['comment_id'] = $comment_id;
        $data['status'] = 1;
        $SchoolComment = M('SchoolComment');

        if (($SchoolComment->where($map)->save($data)) > 0) {
             $this->ajaxReturn($comment_id);
        } else {
             $this->ajaxReturn($comment_id);
        }
    }
	
	
}










